<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<title>个人信息</title>
		<%-- <%@include file="/WEB-INF/base.jspf"%> --%>
<%-- 		<script src="/js/bootstrap-paginator.js"></script> --%>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<script src="/js/jq.js"></script>
<script src="/js/global.js"></script>
<script src="/js/lotterHelper.js"></script>
<script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>
<script src="/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/css/global.css"/>
<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.min.css"/>
		<style type="text/css">
			*{font-size: 14px;}
			
			/* .qiu0{background: #D8D21C!important;} */
			.circle-qiu01{background: #D8D21C!important;}
			.circle-qiu02{background: #3273F9!important;}
			.circle-qiu03{background: #515567!important;}
			.circle-qiu04{background: #E6962D!important;}
			.circle-qiu05{background: #0EC2C4!important;}
			.circle-qiu06{background: #2D35D0!important;}
			.circle-qiu07{background: #AEAFC5!important;}
			.circle-qiu08{background: #E63131!important;}
			.circle-qiu09{background: #7C1F1F!important;}
			.circle-qiu10{background: #2DCC21!important;}
			.yuan{
				    display: inline-block;
				  /*   background: red; */
				    margin: 0 4px;
				    border-radius: 50%;
				    color: white;
				    font-size: 14px;
				    width: 22px;
				    height: 22px;
				    text-align: center;
				    line-height: 22px;
			}
			
			li{height: 60px;line-height: 60px;border-top: 1px solid #f2f2f2;}
			tr{background: white;height: 30px;}
			#div-i-btnGroup {
				background-color: #F1F1F1;
				height:33px;
			}
			#div-i-btnTypeGroup button {
				margin-top:0;
				width:25%;
				font-size:16px;
				border-radius: 1px;
				border: 4px solid transparent;
				transition:all 0.3s;
			}
			.btnTypeActive {
				border: 4px solid #0d7bbb!important;
			}
			#div-i-btnTypeGroup {
				background-color: white;
				font-size:0;
			}
			#div-i-btnGroup select {
				margin-top:0;
				color:#059BF3;
				outline: none;
				font-size:18px;
				font-weight:bold;
				border:none;
				width:100%;
			}
			.tr {
				cursor: pointer;
			}
			#table-i-myOrdersList {
				border-bottom:none;
			}
			#tbody-i-dataWrapper td {
				padding-left:0;
				padding-right:0;
			}
			.hiddenLotterNumberLine span {
				word-break:break-all;
				white-space:normal;
			}
			.ordertableInfo {
				display:flex;
				flex-direction:column;
			}
			.dataTables_wrapper .dataTables_paginate {
				text-align: center;
			}
			.tableSearch {
				justify-content:center;
				padding-top:10px;
			}
			.class-input-pageNumberTwo {
				margin-right:6px;
			}
			.hidden-td {
				display:none;
			}
			
			.shaizi{
			width: 28px !important;
    		height: 28px !important;
		}
		
		.klsf{
			width: 28px !important;
    		height: 28px !important;
    		margin-right: 5px;
		}
			
			.circle-qiu {
			display:inline-block;background:red;margin:0 4px;border-radius:50%;color:white;font-size:14px;width:22px;height:22px;text-align:center;line-height:22px;}
		</style>
	</head>

	<body style="background: #F1F1F1;">
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center" style="padding:0;position: fixed;margin-top: 0px;left: 0px;z-index: 100;background-color:#059BF3;">
			<div style="padding:11px;position: relative;">
				<a onclick="back()" class="glyphicon glyphicon-chevron-left fl" style="cursor:pointer; color: white;position:absolute;top:50%;transform:translateY(-50%);font-size: 20px;left:10px;"></a>
				<strong style="font-size: 20px;color:white;">我的订单</strong>
			</div>
			<div id="div-i-btnTypeGroup">
				<button class="btn btn-xs btn-warning" data-type="1">待开奖</button>
				<button class="btn btn-xs btn-danger" data-type="2">未中奖</button>
				<button class="btn btn-xs btn-success" data-type="3">已中奖</button>
				<button class="btn btn-xs btn-info" data-type="7">已撤单</button>
			</div>			
			<div id="div-i-btnGroup">
				<select id="select-i-caizhongTypes">
					<option value="">全部彩种(点击选择)</option>
				</select>
			</div>
		</div>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4" style="padding: 0px;">
			<div style="height: 118px;"></div>
			
			<table id="table-i-myOrdersList" class="class-tableDataTable" style="max-width: 100%;min-width:100%;">
				<thead style="display:none;">
					<tr>
						<td></td>
						<td></td>
						<td></td>
					</tr>
				</thead>
				<tbody id="tbody-i-dataWrapper">
				</tbody>
			</table>
		</div>
<div class="modal-div-fakeModal" id="div-i-ConfirmNotice" >
	<div class="div-c-modalContent">
		<h3 class="fakemodal-title"></h3>
		<div class="fakemodal-content"></div>
		<div class="fakemodal-btnsGroup">
			<button class="btn-c-confirmYES btn btn-success">确认</button>
			<button class="btn btn-default btn-class-closeFakeModal">关闭</button>
		</div>
	</div>
</div>		
<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
	<div class="div-c-modalContent">
		<h3 class="fakemodal-title"></h3>
		<div class="fakemodal-content"></div>
		<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal div-guanbi">关闭</button></div>
	</div>
</div>		
	</body>
	<script type="text/javascript">
	var cp={
			"北京PK拾":"bjpk10" ,
			"二分PK拾":"2fpk10",
			"幸运飞艇":"xyft",
			"幸运赛马":"xysm",
			"重庆时时彩":"cqssc",
			"二分时时彩":"2fssc",
			"天津时时彩":"tjssc", 
			"新疆时时彩":"xjssc",
			"广东快乐十分":"gdkl10f", 
			"重庆快乐十分":"cqkl10f", 
			"安徽11选5":"ah11x5", 
			"广东11选5":"gd11x5",
			"江西11选5":"jx11x5", 
			"山东11选5":"sd11x5",
			"上海11选5":"sh11x5", 
			"香港六合彩 ":"xg6hc", 
			"五分六合彩":"5f6hc",
			"上海时时乐":"shssl", 
			"排列三":"pl3", 
			"福彩3D":"fc3d", 
			"安徽快3":"ahk3", 
			"广西快3":"gxk3",
			"江苏快3":"jsk3", 
			"北京快3":"bjk3", 
			"吉林快3":"jlk3", 
			"三分快3":"3fk3",
	}
	var colorObj = {
		"1": {"type": "0", "color": "blue", "text": "待开奖",},
		"2": {"type": "1", "color": "red", "text": "未中奖", },
		"3": {"type": "2", "color": "green", "text": "中奖", },
		"6": {"type": "2", "color": "green", "text": "和局", },
		"7": {"type": "3", "color": "gray", "text": "已撤单", },
		"8": {"type": "3", "color": "gray", "text": "官方异常", }, 
	}	
 	$.ajax({
		 type:"post",
		 url:"/order/myOrderLotters.do",
		 success: function(data) {
			var newData=data.data
			console.log(newData)
			  for(i=0;i<newData.length;i++){
			 	var item=newData[i]; 
				var option="<option data-type="+item.cname+">"+item.cname1+"</option>" 
				$("#select-i-caizhongTypes").append(option);
 			}  
		 } 
	}) 
	
		 
 	function checkItemZhongJiangStatus(item) {
		var yuanValue = ""
		var stateValue = item.state
		var t = colorObj[String(stateValue)]
		var textValue = t.text
		if (t.type === "2") {
			// 是不是 0元 ？
			if (stateValue === 6) {
				var allMoney = 0
				for (var i = 1; i < 8; i++) {
					allMoney += item["money" + i]
				}
				if (item.goalmoney === 0) {
					yuanValue = "退还本金" + String(allMoney) + "元"
					//yuanValue = String(item.goalmoney) + "元"
				} else {
					textValue = "中奖"
					yuanValue = String(item.goalmoney) + "元,<br>" + "和局退还本金" + String(allMoney) + "元"
				}
			} else {
				yuanValue = String(item.goalmoney) + "元"
			}
		}
		var html = '<span class="span-c-resultStatus"  data-type="' + t.type + '" style="color: ' + t.color + ';font-weight: bold;">' + textValue + yuanValue + '</span>'
		return html
	}
		
	 function lotterItemPart2(item) {
		var btnHTML = ""
		if (item.state === 1 && item.cname != "xg6hc") {
			btnHTML = '<a class="btn btn-default btn-sm killOrder" data="' + item.id + '" >撤单</a>'
		}
/* 		else if (item.state > 1) {
			btnHTML = '<a class="btn btn-default btn-sm del" data="' + item.id + '" >删除</a>'
		} */
		return '<div style="padding-left:10px;padding-right:10px;padding-top:6px;display:flex;justify-content:space-between;align-items:center;">'+
		'<span style="color:silver;">点击查看详情</span>'+
		'<span>' + btnHTML + '</div></div>'
	}
	
	 function lotterItemPart3(item) {
		var wanfaHTML = ""
		for (var i = 1; i < 41; i++) {
			var strValue = item["str" + String(i)]
			if (strValue) {
				wanfaHTML += '<span style=""><span style="color:black;font-weight:bold;">' + item["cplay" + String(i)] + '：</span><span style="font-weight:bold;color:red;">' + strValue + '</span></span>'
			}
		}
		return '<div class="parentTr hidden xxxx hiddenLotterNumberLine" style="padding-left: 10px;font-size: 14px;display:flex;flex-direction:column;">' + wanfaHTML + '</div>'
	}
		
	 function createNewLotterItem(dataObj) {
		var acountYuan = dataObj.acount == "" ? "" : "元"
		var zhongjianStatus = checkItemZhongJiangStatus(dataObj)
		var kaijianghaoma = dataObj.lotternum == null ? "" : dataObj.lotternum
		var startDiv = '<div style="display:flex;flex-direction:column;">'
		
		var part1 = '<div style="flex-grow:1;">'+
		'<div class="' + dataObj.cname + '" style="border-top: 10px solid #F1F1F1;display:flex;padding-top:6px;">'+
			'<span style="flex:1;text-align: center;">' + dataObj.cname1 + '</span>'+
			'<span style="flex:1;text-align: center;font-weight:bold;"><span class="period-current">' + dataObj.period + '</span>期</span>'+
			'<span style="flex:1;text-align: right;padding-right:8px;"><span class="killOrderNeedMoney" style="font-weight:bold;color:red;">' + dataObj.acount + '</span>'+
				acountYuan +
			'</span>'+
		'</div>'+
		'<div class="' + dataObj.cname + '" style="color: silver ;display:flex;padding-top:6px;">'+
			'<span style="flex:1;text-align: center;">'+
			zhongjianStatus +
			'</span>'+
			'<span style="flex:1;text-align: center;">' + dataObj.orderdate + '</span>'+
			'<span style="flex:1;text-align: center;color:black;">'+
				'共 <span style="font-weight:bold;color:red;">' + dataObj.lottercount + '</span> 注'+
			'</span>'+
		'</div>'+
		'<div class="parentTr tr" style="color: silver ;padding-top:6px;">'+
			'<span class="kaijiang" style="text-align: left;">' + kaijianghaoma + '</span>'+
		'</div>'+
	'</div>'
		var part2 = lotterItemPart2(dataObj)
		var part3 = lotterItemPart3(dataObj)
		return part1 + part2 + part3
	}
	 
	 $(".div-guanbi").on("click",function(){
		 window.location.reload()
	 })
		
	var isFirstFlag = true
	var DATATABLE_I = 0
	 function initDataTable(){
		$("#table-i-myOrdersList").DataTable({
				 "bProcessing" : false, // 是否显示取数据时的那个等待提示
				"bServerSide" : true,//这个用来指明是通过服务端来取数据
				 "bPaginate" : true, //是否显示分页 
				"sAjaxSource" : "/order/myOrders.do",//这个是请求的地址
				"fnServerData" : retrieveData, // 获取数据的处理函数
				"destroy":true,
				 columnDefs: [{"defaultContent": "",
                     "targets": "_all"}],
			       // "bPaginate": true,
			       // "bPaginate": true,
			      "bLengthChange": true,      
			      "bSort": false,
			      "bLengthChange": true,      
			      "bAutoWidth": false,
			      "bSort": false,
			      "dom": "t<'ordertableInfo'ip<'tableSearch'>>",
			      'aLengthMenu':[10],
			       "searching": true,  
			       "language": {//语言设置  
			            "lengthMenu": "每页显示 _MENU_ 条记录",     
			            "zeroRecords": "暂无下注记录",     
			            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
			            "info": "没有数据",     
			            "oPaginate": {     
			                "sFirst": "首页",     
			                "sPrevious": "上页",     
			                "sNext": "下页",     
			                "sLast": "尾页"    
			          	},
			            "search":"搜索:",
			            "infoFiltered": "",
			            "infoEmpty": "",
			         },  
			         "aoColumns": [
			        	 {"data": "cname", "className": "hidden-td id-edit-td"},
	                     {"data": "state", "className": "hidden-td number-edit-td"},
	                     {"data": "content", "className": "note-edit-td"},
	                 ],
	                 "drawCallback": function() {
	  		        	var allKaiJiangs = $(".kaijiang")
	  		        	
	  		        	for (var i = 0; i < allKaiJiangs.length; i++) {
	  		        		var item2 = allKaiJiangs[i]
	  		        		console.log(item2)
	  		        		if ($(item2).find(".circle-qiu").length !== 0) {
	  		        			continue
	  		        		}
	  		        		var lotterNumArr = item2.innerText.trim().split(",")
	  		        		var bgColor=""
	  		        		var html = ""
	 	        			var xg6hcBackGround = ""
	 	        			var xg6hcColor=""
	 	        			for (var j = 0; j < lotterNumArr.length; j++) {
	  		        			var item = lotterNumArr[j]
	  		        			console.log(item)
	  		        			if (!item) {
	  		        				continue
	  		        			}
	  		        			if($(item2).closest("tr").find(".id-edit-td").text() === "2fpk10" || $(item2).closest("tr").find(".id-edit-td").text() === "bjpk10"|| $(item2).closest("tr").find(".id-edit-td").text() === "xyft"|| $(item2).closest("tr").find(".id-edit-td").text() === "xysm"){
	  		        				xg6hcBackGround="qiu"+item;
	  		        				console.log(xg6hcBackGround)
	  		        				var temp = "<span class='yuan circle-qiu"+ item +"'>" + item + "</span>"
		  		        			html += temp
	  		        			}else if($(item2).closest("tr").find(".id-edit-td").text() === "3fk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "jsk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "ahk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "gxk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "bjk3"){
	  		        				var temp="<span class='shaizi sz"+item+"'></span>"
	  		        				html += temp
	  		        			}else if($(item2).closest("tr").find(".id-edit-td").text() === "gdkl10f" || $(item2).closest("tr").find(".id-edit-td").text() === "cqkl10f"){
	  		        				var temp="<span class='klsf sg"+item+"'></span>"
	  		        				html += temp
	  		        			}
	  		        			else if ($(item2).closest("tr").find(".id-edit-td").text() === "xg6hc" || $(item2).closest("tr").find(".id-edit-td").text() === "5f6hc") {
	 								if (blueArr.indexOf(item) != -1) {
	 									xg6hcBackGround = "style='background-color:#336DCC;'"
	 								}
	 								else if (greenArr.indexOf(item) != -1) {
	 									xg6hcBackGround = "style='background-color:#09B832;'"
	 								}
	 								var temp = "<span class='circle-qiu' " +xg6hcBackGround + ">" + item + "</span>"
		  		        			html += temp
	 								
	 							}
	  		        			else{
	  		        				console.log("我最丑")
	 								var temp = "<span class='circle-qiu' " + xg6hcBackGround + ">" + item + "</span>"
		  		        			html += temp
	 							}
	  		        			xg6hcBackGround = "style='background-color:red;'"
	  		        		}
	  		        		$(item2).html(html)
	  		        		
	  		        		if ($(item2).closest("tr").find(".id-edit-td").text() === "xg6hc" || $(item2).closest("tr").find(".id-edit-td").text() === "5f6hc") {
	  		        			var $allYuanNodes = $(item2).find(".circle-qiu")
	  		        			var xg6hcColor =$allYuanNodes.eq($allYuanNodes.length - 1)
	  	 		        		$allYuanNodes.eq($allYuanNodes.length - 1).before("<span style='display:inline-flex;margin:1px;color:black;font-size:20px;width:22px;height:22px;justify-content:center;align-items:center;max-width:22px;max-height:22px;'>+</span>")
	  		        		}
	  		        	}
	 		        }
			})
			function retrieveData(sSource, aoData, fnCallback) {
						$.ajax({
							url : sSource,//这个就是请求地址对应sAjaxSource
							data : {
								"pageCount":aoData[0].value,
								"startIndex":aoData[3].value,
								"lineCount":aoData[4].value,
								"cname":"",
								"state":10
							},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
							type : 'post',
							dataType : 'json',
							async : false,
							success : function(result) {
								var newArr = []
				  				if (result.aaData.length == 0) {
				  					showNoResultNoticeModal("#div-i-noticeGenDan", "提示", "目前您还没有下注记录", "点击前往，立刻下注！", getXiaZhuUrl())
				  					return []
				  				}
				        		 for (var i = 0; i < result.aaData.length; i++) {
				        			var newObj = {}
				        			var item = result.aaData[i]
				        			newObj.cname = item.cname
				        			newObj.state = item.state === 8 ? String(item.state) + "7" : item.state
		        					newObj.state = item.state === 6 ? String(item.state) + "3" : item.state		
				        			newObj.content = createNewLotterItem(item)
				        			newArr.push(newObj)
				        		 }
			  		        	if (isFirstFlag) {
			  		        		DATATABLE_I = "1"
			  		        			/* initDataTable() 
			 		        		/* $("#table-i-myOrdersList").DataTable().ajax.reload() */
			 		        		isFirstFlag = false
			 		        	}		        	
								result.aaData = newArr;
								fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
							}
						})
				}
			}
		 initDataTable()
		 
	var IS_USER_MOVE = false
	$("#table-i-myOrdersList").on("touchstart", "tr", function(e) {
		IS_USER_MOVE = false
	})
	$("#table-i-myOrdersList").on("touchmove", "tr", function(e) {
		IS_USER_MOVE = true
	})	
	
	$("#table-i-myOrdersList").on(getEndClickEvent(), "tr", function(e) {
		if (IS_USER_MOVE) {
			return
		}
		$(e.currentTarget).find(".hiddenLotterNumberLine").toggleClass("hidden")
	})
 		
		var AJAX_OBJ = {}
		
		$(".btn-c-confirmYES").on(getEndClickEvent(), function(e) {
			e.stopPropagation()
			ajax(AJAX_OBJ)
		})
		
		$("#table-i-myOrdersList").on(getEndClickEvent(), ".killOrder", function(e){
			var isClickCheDanbtn = $(this)
			if (IS_USER_MOVE) {
				return
			}	
			var $parentTr = $(e.currentTarget).closest("tr")
			var cname = $parentTr.find(".id-edit-td").text()
			e.stopPropagation()
 			$.ajax({
				url:'/lotter/getnewdata.do',
				type:'post',
				data:{key: cname},
				dataType:"json",
				success:function(data){
					var currentT = new Date(transDateLetter(data.message)).getTime()
					var currentTime = Math.floor(currentT / 1000)
					var nextT = new Date(transDateLetter(data.data.nextStopOrderTimeEpoch)).getTime()
					var nextTime = Math.floor(nextT / 1000) 
					if (nextTime > currentTime && nextTime - currentTime <= 30) {
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "该彩种已经封盘，无法进行撤单操作")
						return
					}
					if (currentTime >= nextTime) {
						// 当前时间大于下次开奖的时间
						var timespace = Number(data.data.timespace)
						var qihao = $parentTr.find(".period-current").text()
						if (Number(qihao.slice(-3)) >= 96 &&  Number(qihao.slice(-3)) <= 24  && cname === "cqssc") {
							timespace = 300
						}	
						if (currentTime > nextTime && Number(qihao) === Number(data.data.period) + 1) {
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "该彩种已经封盘，无法进行撤单操作")
							return
						}
						if (nextTime + timespace - currentTime <= 30) {
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "该彩种已经封盘，无法进行撤单操作")
							return							
						}
					}
					showNormalNoticeModal("#div-i-ConfirmNotice", "提示", "确定撤销这条订单吗?")
						var id = isClickCheDanbtn.attr("data")
						var money = isClickCheDanbtn.closest("tr").find(".killOrderNeedMoney").text()
						AJAX_OBJ = {
								url:'/order/chedan.do',
								data: {
									id: id,
									money: money
								},
								type:'post',
								success:function(data){
									$("#div-i-ConfirmNotice")[0].style.display="none";
									var json=eval('('+data+')');
									showNormalNoticeModal("#div-i-noticeGenDan", "提示",json.message)
									if(json.data===3){
										$("#table-i-myOrdersList").DataTable().row($(e.currentTarget).closest("tr")).remove().draw()
										$("#div-i-ConfirmNotice .btn-class-closeFakeModal").trigger(getNormalClickEvent())
									}	
								}
							}					
						},
						error: function(error){
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络繁忙")
						}						
				})
		})
		
		
		
		$("#table-i-myOrdersList").on(getEndClickEvent(), ".del", function(e){
			if (IS_USER_MOVE) {
				return
			}		
			e.stopPropagation()
			showNormalNoticeModal("#div-i-ConfirmNotice", "提示", "确定删除这条记录吗?")
			AJAX_OBJ = {
				url:'/order/delOrderById.do?id='+$(this).attr("data"),
				type:'post',
				success:function(data){
					var json=eval('('+data+')');
					$("#div-i-ConfirmNotice .btn-class-closeFakeModal").trigger(getEndClickEvent())
					if(json.data==1){
						showNormalNoticeModal("#div-i-noticeGenDan", "提示","删除成功")
				/* 		setTimeout(function() { */
							//location.reload();	
				$("#div-i-ConfirmNotice .btn-class-closeFakeModal").trigger(getNormalClickEvent())
						$("#table-i-myOrdersList").DataTable().row($(e.currentTarget).closest("tr")).remove().draw()
					/* 	}, 1500)	 */					
						}
					else{showNormalNoticeModal("#div-i-noticeGenDan", "提示","删除失败")}
				}				
			}
		});
		 
		$("#div-i-btnTypeGroup button").on(getEndClickEvent(), function(e) {
			var $self = $(e.currentTarget)
			if ($self.hasClass("btnTypeActive")) {
				$self.removeClass("btnTypeActive")
			} else {
				$self.siblings().removeClass("btnTypeActive")
				$self.addClass("btnTypeActive")
			}
			var typeValue = $(".btnTypeActive").length === 0 ? "" : $(".btnTypeActive").attr("data-type")
			var caizName=$("#select-i-caizhongTypes").val()
			if(caizName!=""){
				console.log(caizName)
				caizName=cp[caizName]
			}
			console.log(caizName)
					if(typeValue==""){
						return 
					}else{ 
					$("#table-i-myOrdersList").DataTable({
						 "bProcessing" : false, // 是否显示取数据时的那个等待提示
						"bServerSide" : true,//这个用来指明是通过服务端来取数据
						 "bPaginate" : true, //是否显示分页 
						"sAjaxSource" : "/order/myOrders.do",//这个是请求的地址
						"fnServerData" : retrieveData, // 获取数据的处理函数
						"destroy":true,
						 columnDefs: [{"defaultContent": "",
		                     "targets": "_all"}],
					       // "bPaginate": true,
					       // "bPaginate": true,
					      "bLengthChange": true,      
					      "bSort": false,
					      "bLengthChange": true,      
					      "bAutoWidth": false,
					      "bSort": false,
					      "dom": "t<'ordertableInfo'ip<'tableSearch'>>",
					      'aLengthMenu':[10],
					       "searching": true,  
					       "language": {//语言设置  
					            "lengthMenu": "每页显示 _MENU_ 条记录",     
					            "zeroRecords": "暂无下注记录",     
					            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
					            "info": "没有数据",     
					            "oPaginate": {     
					                "sFirst": "首页",     
					                "sPrevious": "上页",     
					                "sNext": "下页",     
					                "sLast": "尾页"    
					          	},
					            "search":"搜索:",
					            "infoFiltered": "",
					            "infoEmpty": "",
					         },  
					         "aoColumns": [
					        	 {"data": "cname", "className": "hidden-td id-edit-td"},
			                     {"data": "state", "className": "hidden-td number-edit-td"},
			                     {"data": "content", "className": "note-edit-td"},
			                 ],
			                 "drawCallback": function() {
			  		        	var allKaiJiangs = $(".kaijiang")
			  		        	for (var i = 0; i < allKaiJiangs.length; i++) {
			  		        		var item2 = allKaiJiangs[i]
			  		        		if ($(item2).find(".circle-qiu").length !== 0) {
			  		        			continue
			  		        		}
			  		        		var lotterNumArr = item2.innerText.trim().split(",")
			  		        		var html = ""
			 	        			var xg6hcBackGround = ""
			 	        			var xg6hcColor=""
			 	        			for (var j = 0; j < lotterNumArr.length; j++) {
			  		        			var item = lotterNumArr[j]
			  		        			if (!item) {
			  		        				continue
			  		        			}
			  		        			if($(item2).closest("tr").find(".id-edit-td").text() === "2fpk10" || $(item2).closest("tr").find(".id-edit-td").text() === "bjpk10"|| $(item2).closest("tr").find(".id-edit-td").text() === "xyft"|| $(item2).closest("tr").find(".id-edit-td").text() === "xysm"){
			  		        				xg6hcBackGround="qiu"+item;
			  		        				console.log(xg6hcBackGround)
			  		        				var temp = "<span class='yuan circle-qiu"+ item +"'>" + item + "</span>"
				  		        			html += temp
			  		        			}
				 	        			else if($(item2).closest("tr").find(".id-edit-td").text() === "3fk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "jsk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "ahk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "gxk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "bjk3"){
			  		        				var temp="<span class='shaizi sz"+item+"'></span>"
			  		        				html += temp
			  		        			}
				 	        			else if($(item2).closest("tr").find(".id-edit-td").text() === "gdkl10f" || $(item2).closest("tr").find(".id-edit-td").text() === "cqkl10f"){
			  		        				var temp="<span class='klsf sg"+item+"'></span>"
			  		        				html += temp
			  		        			}
			  		        			else if ($(item2).closest("tr").find(".id-edit-td").text() === "xg6hc" || $(item2).closest("tr").find(".id-edit-td").text() === "5f6hc") {
			 								if (blueArr.indexOf(item) != -1) {
			 									xg6hcBackGround = "style='background-color:#336DCC;'"
			 								}
			 								else if (greenArr.indexOf(item) != -1) {
			 									xg6hcBackGround = "style='background-color:#09B832;'"
			 								}
			 								var temp = "<span class='circle-qiu' " +xg6hcBackGround + ">" + item + "</span>"
				  		        			html += temp
			 								
			 							}
			  		        			else{
			 								var temp = "<span class='circle-qiu' " + xg6hcBackGround + ">" + item + "</span>"
				  		        			html += temp
			 							}
			  		        			xg6hcBackGround = "style='background-color:red;'"
			  		        		}
			  		        		$(item2).html(html)
			  		        		if ($(item2).closest("tr").find(".id-edit-td").text() === "xg6hc" || $(item2).closest("tr").find(".id-edit-td").text() === "5f6hc") {
			  		        			var $allYuanNodes = $(item2).find(".circle-qiu")
			  		        			var xg6hcColor =$allYuanNodes.eq($allYuanNodes.length - 1)
			  	 		        		$allYuanNodes.eq($allYuanNodes.length - 1).before("<span style='display:inline-flex;margin:1px;color:black;font-size:20px;width:22px;height:22px;justify-content:center;align-items:center;max-width:22px;max-height:22px;'>+</span>")
			  		        		}
			  		        	}
			 		        }
					})
					
					function retrieveData(sSource, aoData, fnCallback) {
								$.ajax({
									url : sSource,//这个就是请求地址对应sAjaxSource
									data : {
										"pageCount":aoData[0].value,
										"startIndex":aoData[3].value,
										"lineCount":aoData[4].value,
										"cname":caizName,
										"state":typeValue
									},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
									type : 'post',
									dataType : 'json',
									async : false,
									success : function(result) {
										var newArr = []
						  				/* if (result.aaData.length == 0) {
						  					showNoResultNoticeModal("#div-i-noticeGenDan", "提示", "目前您还没有下注记录", "点击前往，立刻下注！", getXiaZhuUrl())
						  					return []
						  				} */
						        		 for (var i = 0; i < result.aaData.length; i++) {
						        			var newObj = {}
						        			var item = result.aaData[i]
						        			newObj.cname = item.cname
						        			newObj.state = item.state === 8 ? String(item.state) + "7" : item.state
				        					newObj.state = item.state === 6 ? String(item.state) + "3" : item.state		
						        			newObj.content = createNewLotterItem(item)
						        			newArr.push(newObj)
						        		 }
					  		         	if (isFirstFlag) {
					  		        		DATATABLE_I = "1"
					  		        			 initDataTable() 
					 		        		/* $("#table-i-myOrdersList").DataTable().ajax.reload() */
					 		        		isFirstFlag = false
					 		        	}		        	
										result.aaData = newArr;
										fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
									}
								})
						}
					}
			/* $("#table-i-myOrdersList").DataTable() */
			/* .column(0).search($("#select-i-caizhongTypes").val())
			.column(1).search(typeValue)
			.draw()	 */
		})
		$("#select-i-caizhongTypes").on("change", function(e) {
			
			  var typeValue = $(".btnTypeActive").length === 0 ? "" : $(".btnTypeActive").attr("data-type") 
				if(typeValue==""){
					typeValue=10
				}
			 var caizName=$(this).val()
			 if(caizName!=""){
				 caizName=cp[caizName] 
			 }
			$("#table-i-myOrdersList").DataTable({
						 "bProcessing" : false, // 是否显示取数据时的那个等待提示
						"bServerSide" : true,//这个用来指明是通过服务端来取数据
						 "bPaginate" : true, //是否显示分页 
						"sAjaxSource" : "/order/myOrders.do",//这个是请求的地址
						"fnServerData" : retrieveData, // 获取数据的处理函数
						"destroy":true,
						 columnDefs: [{"defaultContent": "",
		                     "targets": "_all"}],
					       // "bPaginate": true,
					       // "bPaginate": true,
					      "bLengthChange": true,      
					      "bSort": false,
					      "bLengthChange": true,      
					      "bAutoWidth": false,
					      "bSort": false,
					      "dom": "t<'ordertableInfo'ip<'tableSearch'>>",
					      'aLengthMenu':[10],
					       "searching": true,  
					       "language": {//语言设置  
					            "lengthMenu": "每页显示 _MENU_ 条记录",     
					            "zeroRecords": "暂无下注记录",     
					            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
					            "info": "没有数据",     
					            "oPaginate": {     
					                "sFirst": "首页",     
					                "sPrevious": "上页",     
					                "sNext": "下页",     
					                "sLast": "尾页"    
					          	},
					            "search":"搜索:",
					            "infoFiltered": "",
					            "infoEmpty": "",
					         },  
					         "aoColumns": [
					        	 {"data": "cname", "className": "hidden-td id-edit-td"},
			                     {"data": "state", "className": "hidden-td number-edit-td"},
			                     {"data": "content", "className": "note-edit-td"},
			                 ],
			                 "drawCallback": function() {
			  		        	var allKaiJiangs = $(".kaijiang")
			  		        	for (var i = 0; i < allKaiJiangs.length; i++) {
			  		        		var item2 = allKaiJiangs[i]
			  		        		if ($(item2).find(".circle-qiu").length !== 0) {
			  		        			continue
			  		        		}
			  		        		var lotterNumArr = item2.innerText.trim().split(",")
			  		        		var html = ""
			 	        			var xg6hcBackGround = ""
			 	        			var xg6hcColor=""
			 	        			for (var j = 0; j < lotterNumArr.length; j++) {
			  		        			var item = lotterNumArr[j]
			  		        			if (!item) {
			  		        				continue
			  		        			}
			  		        			if($(item2).closest("tr").find(".id-edit-td").text() === "2fpk10" || $(item2).closest("tr").find(".id-edit-td").text() === "bjpk10"|| $(item2).closest("tr").find(".id-edit-td").text() === "xyft"|| $(item2).closest("tr").find(".id-edit-td").text() === "xysm"){
			  		        				xg6hcBackGround="qiu"+item;
			  		        				console.log(xg6hcBackGround)
			  		        				var temp = "<span class='yuan circle-qiu"+ item +"'>" + item + "</span>"
				  		        			html += temp
			  		        			}
				 	        			else if($(item2).closest("tr").find(".id-edit-td").text() === "3fk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "jsk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "ahk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "gxk3" ||$(item2).closest("tr").find(".id-edit-td").text() === "bjk3"){
			  		        				var temp="<span class='shaizi sz"+item+"'></span>"
			  		        				html += temp
			  		        			}
				 	        			else if($(item2).closest("tr").find(".id-edit-td").text() === "gdkl10f" || $(item2).closest("tr").find(".id-edit-td").text() === "cqkl10f"){
			  		        				var temp="<span class='klsf sg"+item+"'></span>"
			  		        				html += temp
			  		        			}
			  		        			else if ($(item2).closest("tr").find(".id-edit-td").text() === "xg6hc" || $(item2).closest("tr").find(".id-edit-td").text() === "5f6hc") {
			 								if (blueArr.indexOf(item) != -1) {
			 									xg6hcBackGround = "style='background-color:#336DCC;'"
			 								}
			 								else if (greenArr.indexOf(item) != -1) {
			 									xg6hcBackGround = "style='background-color:#09B832;'"
			 								}
			 								var temp = "<span class='circle-qiu' " +xg6hcBackGround + ">" + item + "</span>"
				  		        			html += temp
			 								
			 							}
			  		        			else{
			 								var temp = "<span class='circle-qiu' " + xg6hcBackGround + ">" + item + "</span>"
				  		        			html += temp
			 							}
			  		        			xg6hcBackGround = "style='background-color:red;'"
			  		        		}
			  		        		$(item2).html(html)
			  		        		if ($(item2).closest("tr").find(".id-edit-td").text() === "xg6hc" || $(item2).closest("tr").find(".id-edit-td").text() === "5f6hc") {
			  		        			var $allYuanNodes = $(item2).find(".circle-qiu")
			  		        			var xg6hcColor =$allYuanNodes.eq($allYuanNodes.length - 1)
			  	 		        		$allYuanNodes.eq($allYuanNodes.length - 1).before("<span style='display:inline-flex;margin:1px;color:black;font-size:20px;width:22px;height:22px;justify-content:center;align-items:center;max-width:22px;max-height:22px;'>+</span>")
			  		        		}
			  		        	}
			 		        }
					})
					
					function retrieveData(sSource, aoData, fnCallback) {
								$.ajax({
									url : sSource,//这个就是请求地址对应sAjaxSource
									data : {
										"pageCount":aoData[0].value,
										"startIndex":aoData[3].value,
										"lineCount":aoData[4].value,
										"cname":caizName,
										"state":typeValue,
									},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
									type : 'post',
									dataType : 'json',
									async : false,
									success : function(result) {
										var newArr = []
						  				/* if (result.aaData.length == 0) {
						  					showNoResultNoticeModal("#div-i-noticeGenDan", "提示", "目前您还没有下注记录", "点击前往，立刻下注！", getXiaZhuUrl())
						  					return []
						  				} */
						        		 for (var i = 0; i < result.aaData.length; i++) {
						        			var newObj = {}
						        			var item = result.aaData[i]
						        			console.log(item)
						        			newObj.cname = item.cname
						        			newObj.state = item.state === 8 ? String(item.state) + "7" : item.state
				        					newObj.state = item.state === 6 ? String(item.state) + "3" : item.state		
						        			newObj.content = createNewLotterItem(item)
						        			newArr.push(newObj)
						        		 }
					  		         	if (isFirstFlag) {
					  		        		DATATABLE_I = "1"
					  		        			 initDataTable() 
					 		        		/* $("#table-i-myOrdersList").DataTable().ajax.reload() */
					 		        		isFirstFlag = false
					 		        	}		        	
										result.aaData = newArr;
										
										fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
									}
								})
						}
			/* $("#table-i-myOrdersList").DataTable() */
			/* .column(0).search($("#select-i-caizhongTypes").val())
			.column(1).search(typeValue)
			.draw()	 */		
		})
	</script>
</html>